﻿Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Xml
Imports System.Reflection


Partial Class 水准路线
    Public 路线名称 As String
    Public 测段数 As String
    Public 起点概略高程 As String
    Public 测量方式 As String
    Public 测量代号 As String
    Public 施测单位 As String
    Public 施测年代 As String
    Public 等级 As String
    Public 起测点 As String
    Public 结束点 As String
    Public 区段选择 As String
    Public 测段选择 As String
    Public 施测方法 As String
    Public 水准仪编号 As String
    Public 观测者 As String
    Public 记录者 As String
    Public 软件名称 As String
    Public 软件单位 As String
    Public 水准仪型号 As String
    Public 乘常数 As String
    Public 加常数 As String
    Public 测微器分划值 As String
    Public 标尺类型 As String
    Public 标尺常数 As String
    Public 标尺间距 As String
    Public 尺承类型 As String
    Public 记录器型号 As String
    Public 记录器编号 As String
    Public 标尺编号 As String




    Public Property 测段s As IList(Of 测段) = New List(Of 测段)()

    Public Shared Function Paras(xxNode As XmlNode) As 水准路线
        Dim tmpClass As 水准路线 = New 水准路线()
        Dim nameList As XmlAttributeCollection = xxNode.Attributes

        For Each xxattribute As XmlAttribute In nameList

            Try

                Dim tmpType As Type = tmpClass.GetType()
                Dim tmpP As FieldInfo = tmpType.GetField(xxattribute.Name)
                tmpP.SetValue(tmpClass, xxattribute.Value)
            Catch ex As Exception

            End Try

        Next


        Dim childList As XmlNodeList = xxNode.ChildNodes  '取得row下的子节点集合   
        For Each xxxNode As XmlNode In childList

            If (xxxNode.Name.Equals("测段")) Then
                Dim tmp测段 As 测段 = 测段.Paras(xxxNode)
                tmp测段.水准路线 = tmpClass
                tmpClass.测段s.Add(tmp测段)
            End If
        Next

        Return tmpClass

    End Function
    '给测段不需要编号
    Public Sub markRouteNO1(ByVal lineno As String)
        Dim i As Integer = 0


        For Each tmp As Object In 测段s
            If (tmp.标志 = "GO0") Then
                ' i = i + 1

                If lineno = Nothing Then
                    tmp.routeNO = Me.路线名称 + String.Format("{0:000}", i)
                Else
                    tmp.routeNO = lineno
                End If

            ElseIf (tmp.标志 = "BK0") Then
                If lineno = Nothing Then
                    tmp.routeNO = Me.路线名称 + String.Format("{0:000}", i)
                Else
                    tmp.routeNO = lineno
                End If
                '  tmp.routeNO = Me.路线名称 + String.Format("{0:000}", i)

                ' i = i - 1
            Else
                If lineno = Nothing Then
                    tmp.routeNO = Me.路线名称 + String.Format("{0:000}", i)
                Else
                    tmp.routeNO = lineno
                End If

                ' tmp.routeNO = Me.路线名称 + String.Format("{0:000}", i)
            End If
        Next



    End Sub

    '给测段编号
    Public Sub markRouteNO()
        Dim i As Integer = 0
        For Each tmp As Object In 测段s
            If (tmp.标志 = "GO0") Then
                i = i + 1
                tmp.routeNO = Me.路线名称 + String.Format("{0:000}", i)
            ElseIf (tmp.标志 = "BK0") Then
                tmp.routeNO = Me.路线名称 + String.Format("{0:000}", i)
                i = i - 1

            ElseIf (tmp.标志 = "RB1") Then
                i = i + 1
                tmp.routeNO = Me.路线名称 + String.Format("{0:000}", i)
                i = i - 1
            Else
                tmp.routeNO = Me.路线名称 + String.Format("{0:000}", i)
            End If
        Next

    End Sub

    'staffNOB=返测_前尺号码     从(of 测段 标志="BK0" 起测点="Ⅰ大榆25-2基上" 前尺号码="34366"获取
    'staffNOG=往测_前尺号码     从(of 测段 标志="GO0" 起测点="山阴(1189)下" 前尺号码="34372"获取

    Public Function getStaffNOG() As String
        Dim a As Object = (From p In 测段s Where p.标志 = "GO0" Select p).FirstOrDefault()
        If IsNothing(a) Then
            Return ""
        Else
            Return a.前尺号码
        End If
    End Function
    Public Function getStaffNOB() As String

        Dim a As Object = (From p In 测段s Where p.标志 = "BK0" Select p).FirstOrDefault()
        If IsNothing(a) Then
            Return ""
        Else
            Return a.前尺号码
        End If
    End Function


End Class
